package cn.edu.bjfu.practice.practice.app.common.response;

/**
 * 错误代码
 */
public class ErrorCode {
    /** 错误码 */
    private int code;

    /** 错误信息 */
    private String message;

    public ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj == null){
            return false;
        }

        if(this == obj){
            return true;
        }

        ErrorCode that = (ErrorCode) obj;
        if(this.getClass() == that.getClass() && this.code == that.code){
            return this.message != null && this.message.equals(that.message);
        }
        return false;
    }

    @Override
    public String toString() {
        return String.format("%04d", this.code);
    }
}

